<template>
	<view class="my">
		<image class="top-bg" mode="aspectFill" src="/static/my/minebg.png"></image>
		<view class="pl-3 pr-3 my-wrap">
			<navigator url="/pages/my/userInfo/userInfo" class="flex align-center mb-3 p-2 personal-info-panel">
				<image class="avatar" mode="aspectFill" :src="'http://img.help10000.com' + userInfo.Logo"></image>
				<view class="f-1 info">
					<u--text lines="1" color="#333" size="32rpx" :text="userInfo.DispName"></u--text>
					<u--text lines="1" color="#333" size="28rpx" :text="currCmpy.CmpyName"></u--text>
					<u--text lines="1" color="#999" size="26rpx" :text="'ID:' + userInfo.AccountID"></u--text>
				</view>
			</navigator>
			<view class="mb-2 cell-wrap">
				<u-cell-group>
					<u-cell icon="/static/my/icon_dz.png" title="我的地址" isLink url="/pages/my/address/address"
						:border="false"></u-cell>
					<u-cell icon="/static/my/go_next.png" title="我的反馈" isLink url="/pages/my/feelback/feelback"
						:border="false"></u-cell>
				</u-cell-group>
			</view>
			<view class="mb-2 cell-wrap">
				<u-cell-group>
					<u-cell icon="/static/my/fx.png" title="分享好友" isLink :border="false"></u-cell>
					<u-cell icon="/static/my/icon_gy.png" title="关于我们" isLink url="/pages/my/aboutUs/aboutUs"
						:border="false"></u-cell>
					<u-cell @click="handleMakePhoneCall" icon="/static/my/icon_kefu.png" title="客服热线" isLink
						:value="serviceTel" :border="false"></u-cell>
				</u-cell-group>
			</view>
			<view class="mb-2 cell-wrap">
				<u-cell-group>
					<u-cell @click="showLogout = true" icon="/static/my/tc.png" title="退出登录" :border="false"></u-cell>
				</u-cell-group>
			</view>
		</view>
		<u-modal :show="showLogout" @confirm="handleLogout" @cancel="showLogout = false" :showCancelButton="true"
			title="退出登录" content='确定退出登录？'></u-modal>

	</view>
</template>

<script>
	import {
		loginOut
	} from "@/apis/user.js";
	export default {
		data() {
			return {
				userInfo: {},
				currCmpy: {},
				showLogout: false,
				serviceTel: '18825282628',
			};
		},
		onShow() {
			const accountInfo = uni.getStorageSync('accountInfo') || {}

			this.userInfo = accountInfo.userInfo ? accountInfo.userInfo : {},
				this.currCmpy = accountInfo.currCmpy ? accountInfo.currCmpy : {},
				console.log('onLoad', this.userInfo, this.currCmpy)
		},
		methods: {
			handleMakePhoneCall() {
				uni.makePhoneCall({
					phoneNumber: this.serviceTel
				});
			},
			async handleLogout() {
				console.log('handleLogout')
				const res = await loginOut()
				if (res.MsgCode != 0) return

				uni.removeStorageSync('accountInfo');
				uni.reLaunch({
					url: '/pages/login/login'
				})
			},
		}
	}
</script>

<style lang="scss">
	.my {
		.top-bg {
			width: 100%;
			height: 272rpx;
			margin-top: -44px;
			z-index: -1;
		}

		.my-wrap {
			margin-top: -140rpx;

			.personal-info-panel {
				background-color: #fff;
				border-radius: $s-border-radius;
				box-shadow: $s-bg-shadow;

				.avatar {
					width: 144rpx;
					height: 144rpx;
					margin-right: 34rpx;
					border-radius: 100%;
				}
			}

			.cell-wrap {
				background-color: #fff;
				border-radius: $s-border-radius;
				box-shadow: $s-bg-shadow;
			}
		}
	}
</style>
